<template>
  <div style="padding: 10px 15px">
    <!-- 查询条件-->
    <div class="filter-container">
      <el-input
        v-model="listQuery.title"
        placeholder="请输入前置机名称"
        style="width: 200px"
        class="filter-item"
        @keyup.enter.native="handleFilter"
      />

      <el-select
        v-model="form.cpnID"
        v-if="this.logincpnid == 'system'"
        filterable
        clearable
        class="filter-item"
        :filter-method="cpnmatch"
        @clear="cpnmatch"
        placeholder="请选择企业"
      >
        <el-option
          v-for="item in cpnoptions"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        >
          <span v-html="item.label" />
        </el-option>
      </el-select>

      <el-button
        class="filter-item seachbttn"
        type="primary"
        icon="el-icon-search"
        @click="handleFilter"
        >查询</el-button
      >
      <el-button
        class="filter-item seachbttn"
        type="primary"
        @click="handleFilter(2)"
      >
        清空
      </el-button>
    </div>
    <div
      class="filter_fenge"
      style="border: none; border-top: 1px solid #d1ddeb"
    />
    <div class="filter-container">
      <el-button
        v-if="Jurisdiction('添加')"
        class="filter-item bttnleft"
        type="primary"
        icon="el-icon-edit"
        @click="handleCreate"
        >新增</el-button
      >
      <el-button
        v-if="Jurisdiction('删除')"
        class="filter-item"
        type="danger"
        icon="el-icon-delete"
        @click="deleteClick()"
        >删除</el-button
      >
    </div>
    <!--查询条件 end-->

    <!--table-->
    <el-table
      ref="multipleTable"
      v-loading="listLoading"
      :data="ActChannelCfgData"
      fit
      highlight-current-row
      style="width: 100%"
      stripe
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" />
      <el-table-column align="left" width="25px" label="">
        <template slot-scope="{ row }">
          <div v-if="row.enablStt == 1">
            <i
              class="el-icon-alarm-clock"
              style="color: orange; display: block"
              v-show="dateCheck(row.actEdtStr) == 1"
              title="该活动即将到期"
            ></i>
            <i
              class="el-icon-alarm-clock"
              style="color: red; display: block"
              v-show="dateCheck(row.actEdtStr) == 0"
              title="该活动已到期"
            ></i>
          </div>
        </template>
      </el-table-column>
      <el-table-column
        v-if="this.logincpnid == 'system'"
        label="企业名称"
        align="left"
        min-width="200px"
      >
        <template slot-scope="{ row }">
          <span>{{ row.cpnIDStr }}</span>
        </template>
      </el-table-column>
      <el-table-column label="前置机名称" align="left" min-width="200px">
        <template slot-scope="{ row }">
          <span>{{ row.actName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="单品渠道" align="left" width="180px">
        <template slot-scope="{ row }">
          <span>{{ row.payChannelStr }}</span>
        </template>
      </el-table-column>
      <el-table-column label="开始日期" align="left" width="113px">
        <template slot-scope="{ row }">
          <span>{{ row.actStdtStr }}</span>
        </template>
      </el-table-column>
      <el-table-column label="结束日期" align="left" width="113px">
        <template slot-scope="{ row }">
          <span>{{ row.actEdtStr }}</span>
        </template>
      </el-table-column>
      <el-table-column label="活动状态" align="left" width="113px">
        <template slot-scope="{ row }">
          <span
            v-if="row.trialStt != 2"
            :class="{
              orgaine: row.enablStt == 0,
              green: row.enablStt == 1,
              red: row.enablStt == 2,
            }"
            >{{ row.enablSttStr }}</span
          >
          <span
            v-if="row.trialStt == 2"
            :class="{
              orgaine: row.enablStt == 0,
              green: row.enablStt == 1,
              red: row.enablStt == 2,
            }"
          />
        </template>
      </el-table-column>
      <el-table-column label="审核状态" align="left" width="113px">
        <template slot-scope="{ row }">
          <span
            :class="{
              orgaine: row.trialStt == 0,
              green: row.trialStt == 1,
              red: row.trialStt == 2,
            }"
            >{{ row.trialSttStr }}</span
          >
        </template>
      </el-table-column>
      <el-table-column label="操作人" align="left" min-width="150px">
        <template slot-scope="{ row }">
          <span>{{ row.operation }}</span>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="420">
        <template slot-scope="scope">
          <el-button
            v-if="Jurisdiction('编辑')"
            type="primary"
            size="mini"
            @click="handleClick(scope.row)"
            >编辑</el-button
          >
          <el-button
            v-if="Jurisdiction('查看详情')"
            type="primary"
            size="mini"
            title="查看详情"
            @click="ShowActDetial(scope.row)"
            >查看详情</el-button
          >
          <el-button
            v-if="
              Jurisdiction('终止活动') &&
              scope.row.trialStt != 0 &&
              scope.row.enablStt != 2
            "
            type="primary"
            size="mini"
            title="终止当前进行的活动"
            @click="NotEnableActChannelCfg(scope.row)"
            >停用活动</el-button
          >
          <el-button
            v-if="
              Jurisdiction('子事件') &&
              scope.row.trialStt == 1 &&
              scope.row.enablStt != 2
            "
            type="primary"
            size="mini"
            title="添加当前活动的子事件活动"
            @click="SubClick(scope.row)"
          >
            <!-- {{scope.row.isexpire}} -->
            <i
              class="el-icon-alarm-clock"
              style="color: orange"
              v-show="scope.row.isexpire == 1"
            ></i>

            <i
              class="el-icon-alarm-clock"
              style="color: red"
              v-show="scope.row.isexpire == 2"
            ></i>
            子事件
          </el-button>
          <el-button
            v-if="Jurisdiction('删除')"
            type="danger"
            size="mini"
            @click="deleteClick(scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="listQuery.total > 0"
      :total="listQuery.total"
      :page.sync="listQuery.page"
      :limit.sync="listQuery.limit"
      @pagination="fetchData(this)"
    />

    <!--table end -->

    <!--弹出层  新增-->
    <el-dialog
      :visible.sync="dialogFormVisible"
      width="60%"
      :before-close="handleClose"
      :show-close="false"
      class="ActChannelCfgInfo"
    >
      <el-form :model="form" :inline="true" label-position="right">
        <el-steps :active="active" finish-status="success">
          <el-step title="单品基础信息" />
          <el-step title="选择单品账户" />
          <el-step title="单品账户规则配置" />
          <el-step title="提交审核" />
        </el-steps>
        <!--单品基础信息-->
        <div :class="{ divshow: divid == 0, divnone: divid != 0 }">
          <div class="first_title">单品基础信息</div>
          <div class="prorate_info">
            <el-form-item
              label="企业"
              v-if="this.logincpnid == 'system'"
              prop="cpnID"
              :rules="[
                { required: true, message: '企业不能为空', trigger: 'change' },
              ]"
            >
              <el-select
                v-model="form.cpnID"
                filterable
                class="filter-item"
                :disabled="subisabled"
                :filter-method="cpnmatch"
                @change="CpnselectFn($event)"
                @clear="cpnmatch"
              >
                <el-option
                  v-for="item in cpnoptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                  <span v-html="item.label" />
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="机构">
              <el-select
                v-model="form.orgID"
                filterable
                class="filter-item"
                placeholder="请选择机构"
                :disabled="subisabled"
                @change="OrgselectFn($event)"
              >
                <el-option
                  v-for="item in orgoptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                  <span v-html="item.label" />
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="活动开始日期">
              <el-col :span="18">
                <el-date-picker
                  v-model="form.actStdt"
                  type="date"
                  placeholder="选择日期"
                  style="width: 100%"
                  format="yyyy-MM-dd"
                />
              </el-col>
            </el-form-item>
            <el-form-item label="活动结束日期">
              <el-col :span="18">
                <el-date-picker
                  v-model="form.actEdt"
                  type="date"
                  placeholder="选择日期"
                  style="width: 85%"
                  format="yyyy-MM-dd"
                />
                <i class="el-icon-info" title="结束日期不填则为长期活动"></i>
              </el-col>
            </el-form-item>

            <el-form-item
              label="前置机"
              prop="cpnID"
              :rules="[
                { required: true, message: '企业不能为空', trigger: 'change' },
              ]"
            >
              <el-select
                v-model="form.pyMchinID"
                filterable
                class="filter-item"
                :disabled="subisabled"
                @change="PyMchselectFn($event)"
              >
                <el-option
                  v-for="item in cpnPyMchinRctListoptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                  <span v-html="item.label" />
                </el-option>
              </el-select>
            </el-form-item>
          </div>
          <div class="prorate_info_title">该前置机关联的所有门店</div>
          <div class="prorate_info_orgs">
            <span v-for="sectorg in selectOrgs" :key="sectorg"
              >{{ sectorg }}、</span
            >
          </div>
        </div>

        <!--选择账户-->
        <div :class="{ divshow: divid == 1, divnone: divid != 1 }">
          <div class="first_title">选择账户</div>
          <div class="seach_org">
            <div class="seach_org_left">
              <div>选择账户</div>
              <div class="seach_org_left_second2">
                <el-select
                  v-model="form.paychannel"
                  clearable
                  filterable
                  class="filter-item"
                  placeholder="请选择支付通道"
                  style="width: 260px"
                >
                  <el-option
                    v-for="item in paytychanneloptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                    <span v-html="item.label" />
                  </el-option>
                </el-select>

                <el-select
                  v-model="form.paytyp"
                  clearable
                  class="filter-item"
                  placeholder="请选择支付方式"
                >
                  <el-option
                    v-for="item in paytypeoptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                    <span v-html="item.label" />
                  </el-option>
                </el-select>
                <el-button
                  class="filter-item"
                  type="primary"
                  icon="el-icon-search"
                  @click="handleFilterAct"
                  >查询
                </el-button>
                <div v-loading="cpnorgLoading" class="cpnorgdata_div">
                  <el-table
                    ref="multipleTable2"
                    v-loading="listLoading"
                    :data="CpnActCfgInfos"
                    :total="10"
                    style="width: 100%"
                    @selection-change="handleSelectionChangeAct"
                    @select="onTableSelect"
                    @select-all="selectAll"
                  >
                    <el-table-column
                      type="selection"
                      width="55"
                      :selectable="checkSelect"
                    />
                    <el-table-column label="账户" align="left" width="400px">
                      <template slot-scope="{ row }">
                        <div style="display: flex; align-items: center">
                          <span v-if="row.typ == 0" class="macinact">主</span>
                          {{ row.alisNme }}
                        </div>
                      </template>
                    </el-table-column>

                    <el-table-column
                      label="方式-渠道"
                      align="left"
                      min-width="110px"
                    >
                      <template slot-scope="{ row }">
                        <span>{{ row.payTypStr }}</span>
                      </template>
                    </el-table-column>
                  </el-table>
                </div>
              </div>

              <pagination
                v-show="listQueryAct.total > 0"
                :total="listQueryAct.total"
                :page.sync="listQueryAct.page"
                :limit.sync="listQueryAct.limit"
                @pagination="fetchDataAct(this)"
              />
            </div>
            <div class="seach_org_right">
              <div>
                已选择账户<span class="clear_all" @click="clearallact"
                  >清空</span
                >
              </div>
              <div class="seach_org_right_second2">
                <!-- 动画效果 -->
                <transition-group tag="div" name="list" appear>
                  <div
                    v-for="sectact in SecmultipleSelectionAct"
                    :key="sectact.id"
                    class="select_org"
                    :title="sectact.alisNme"
                  >
                    {{ sectact.alisNme }}
                    <img
                      src="@/assets/org_close.png"
                      class="orgclose"
                      @click="act_close(sectact)"
                    />
                  </div>
                </transition-group>
              </div>
            </div>
          </div>
        </div>
        <!--账户分流配置-->
        <div :class="{ divshow: divid == 2, divnone: divid != 2 }">
          <div class="first_title">单品账户规则配置</div>
          <div class="rules_Cfg">设置账户单品</div>
          <div class="cpnActCfgInfoActRlue">
            <el-table
              :data="cpnActCfgInfoActRlue"
              style="width: 100%"
              fit
              :span-method="objectSpanMethod"
            >
              <el-table-column label="账户类型" align="left" min-width="100px">
                <template slot-scope="{ row }">
                  <span>{{ row.typ == 0 ? "主账户" : "单品账户" }}</span>
                </template>
              </el-table-column>
              <el-table-column label="账户名称" align="left" min-width="400px">
                <template slot-scope="{ row }">
                  <span
                    >{{ row.payTypStr }}：{{ row.alisNme }}[{{ row.act }}]</span
                  >
                </template>
              </el-table-column>
              <el-table-column label="支付渠道" align="left" min-width="200px">
                <template slot-scope="{ row }">
                  <span>{{ row.payChannelStr }}</span>
                </template>
              </el-table-column>
              <el-table-column label="单品条码" align="left" width="200px">
                <template slot-scope="{ row }">
                  <template v-if="row.typ == 0">
                    <el-input
                      value="—"
                      class="edit-input"
                      size="small"
                      style="width: 130px"
                      :disabled="true"
                    />
                  </template>
                  <template v-else>
                    <el-button
                      type="primary"
                      size="mini"
                      @click="ActivityCfgClick(row)"
                      >单品配置</el-button
                    >
                  </template>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
        <!--预览-->
        <div :class="{ divshow: divid == 3, divnone: divid != 3 }">
          <div class="first_title">预览</div>
          <el-table
            :data="cpnActCfgInfoActRlue"
            style="width: 100%"
            fit
            :span-method="objectSpanMethod"
          >
            <el-table-column label="账户类型" align="left" min-width="100px">
              <template slot-scope="{ row }">
                <span>{{ row.typ == 0 ? "主账户" : "单品账户" }}</span>
              </template>
            </el-table-column>
            <el-table-column label="账户名称" align="left" min-width="400px">
              <template slot-scope="{ row }">
                <span
                  >{{ row.payTypStr }}：{{ row.alisNme }}[{{ row.act }}]</span
                >
              </template>
            </el-table-column>
            <el-table-column label="支付渠道" align="left" min-width="200px">
              <template slot-scope="{ row }">
                <span>{{ row.payChannelStr }}</span>
              </template>
            </el-table-column>
            <el-table-column label="单品条码" align="left" width="100px">
              <template slot-scope="{ row }">
                <template v-if="row.typ == 0">
                  <el-input
                    value="—"
                    class="edit-input"
                    size="small"
                    style="width: 70px"
                    :disabled="true"
                  />
                </template>
                <template v-else>
                  <el-button type="primary" size="mini" @click="showGoods(row)"
                    >查看单品</el-button
                  >
                </template>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button v-if="divid != 0" style="float: left" @click="prv"
          >上一步</el-button
        >
        <el-button type="info" plain @click="dialogFormVisible = false"
          >取 消</el-button
        >
        <el-button v-if="divid < 3 && isnext" type="primary" @click="next()"
          >下一步</el-button
        >
        <el-button v-if="divid == 3" type="primary" @click="saveForm()"
          >确认保存</el-button
        >
      </span>
    </el-dialog>

    <!--子事件-->
    <el-dialog
      :visible.sync="dialogFormVisibleSub"
      width="60%"
      :before-close="handleClose"
      :show-close="false"
      class="ActChannelCfgInfo"
    >
      <el-form :model="SubForm" :inline="true" label-position="right">
        <div class="first_Subtitle">前置机配置基础信息</div>
        <div class="sub_titie_info">
          <div class="infocontent_line">
            <div class="infocontent_item_1">
              <span class="infocontent_item_name">开始日期：</span>
              <span class="infocontent_item_content">{{
                SubForm.actStdtStr
              }}</span>
            </div>
            <div class="infocontent_item_1">
              <span class="infocontent_item_name">结束日期：</span>
              <span class="infocontent_item_content">{{
                SubForm.actEdtStr
              }}</span>
            </div>
            <div class="infocontent_item_1">
              <span class="infocontent_item_name">单品状态：</span>
              <span class="infocontent_item_content">
                <span
                  :class="{
                    orgaine: SubForm.enablStt == 0,
                    green: SubForm.enablStt == 1,
                  }"
                  >{{ SubForm.enablSttStr }}</span
                ></span
              >
            </div>
            <div class="infocontent_item_1">
              <span class="infocontent_item_name">审核状态：</span>
              <span class="infocontent_item_content">
                <span
                  :class="{
                    orgaine: SubForm.trialStt == 0,
                    green: SubForm.trialStt == 1,
                    red: SubForm.trialStt == 2,
                  }"
                  >{{ SubForm.trialSttStr }}</span
                ></span
              >
            </div>
          </div>
          <div class="sub_btton">
            <el-button
              type="primary"
              size="mini"
              class="subbttn"
              @click="handleCreateSub()"
              >添加子事件</el-button
            >
          </div>
        </div>
        <div class="sub_table_info">
          <!--table-->
          <el-table
            v-loading="listLoadingsub"
            :data="ActChannelCfgDataSub"
            fit
            highlight-current-row
            style="width: 100%"
            stripe
          >
            <el-table-column align="left" width="25px" label="">
              <template slot-scope="{ row }">
                <div v-if="row.enablStt == 1">
                  <i
                    class="el-icon-alarm-clock"
                    style="color: orange; display: block"
                    v-show="dateCheck(row.actEdtStr) == 1"
                    title="该活动即将到期"
                  ></i>
                  <i
                    class="el-icon-alarm-clock"
                    style="color: red; display: block"
                    v-show="dateCheck(row.actEdtStr) == 0"
                    title="该活动已到期"
                  ></i>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              v-if="this.logincpnid == 'system'"
              label="企业名称"
              align="left"
              min-width="200px"
            >
              <template slot-scope="{ row }">
                <span>{{ row.cpnIDStr }}</span>
              </template>
            </el-table-column>
            <el-table-column label="前置机名称" align="left" min-width="200px">
              <template slot-scope="{ row }">
                <span>{{ row.actName }}</span>
              </template>
            </el-table-column>

            <el-table-column label="支付渠道" align="left" width="180px">
              <template slot-scope="{ row }">
                <span>{{ row.payChannelStr }}</span>
              </template>
            </el-table-column>
            <el-table-column label="开始日期" align="left" width="113px">
              <template slot-scope="{ row }">
                <span>{{ row.actStdtStr }}</span>
              </template>
            </el-table-column>
            <el-table-column label="结束日期" align="left" width="113px">
              <template slot-scope="{ row }">
                <span>{{ row.actEdtStr }}</span>
              </template>
            </el-table-column>
            <el-table-column label="活动状态" align="left" width="113px">
              <template slot-scope="{ row }">
                <span
                  :class="{
                    orgaine: row.enablStt == 0,
                    green: row.enablStt == 1,
                  }"
                  >{{ row.enablSttStr }}</span
                >
              </template>
            </el-table-column>
            <el-table-column label="审核状态" align="left" width="113px">
              <template slot-scope="{ row }">
                <span
                  :class="{
                    orgaine: row.trialStt == 0,
                    green: row.trialStt == 1,
                    red: row.trialStt == 2,
                  }"
                  >{{ row.trialSttStr }}</span
                >
              </template>
            </el-table-column>
            <el-table-column label="操作人" align="left" min-width="150px">
              <template slot-scope="{ row }">
                <span>{{ row.operation }}</span>
              </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作" width="310">
              <template slot-scope="scope">
                <el-button
                  v-if="Jurisdiction('编辑')"
                  type="primary"
                  size="mini"
                  @click="handleClickSub(scope.row)"
                  >编辑</el-button
                >
                <el-button
                  type="primary"
                  size="mini"
                  title="查看详情"
                  @click="ShowActDetial(scope.row)"
                  >查看详情</el-button
                >
                <el-button
                  v-if="scope.row.trialStt != 0 && scope.row.enablStt != 2"
                  type="primary"
                  size="mini"
                  title="终止当前进行的活动"
                  @click="NotEnableActChannelCfg(scope.row)"
                  >终止</el-button
                >
                <el-button
                  v-if="Jurisdiction('删除')"
                  type="danger"
                  size="mini"
                  @click="deleteClick(scope.row)"
                  >删除
                </el-button>
              </template>
            </el-table-column>
          </el-table>
          <!--table end -->
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisibleSub = false">取 消</el-button>
      </span>
    </el-dialog>

    <!--单品配置-->
    <el-dialog
      width="50%"
      :visible.sync="dialoginnerVisible"
      append-to-body
      :before-close="handleClose"
      :show-close="false"
      class="goodsdialg"
    >
      <el-form :model="rules_form" :inline="false" label-position="top">
        <el-form-item
          v-if="this.form.actTyp == 0"
          label="单品条码"
          class="Rule"
        >
          <el-input
            v-model="rules_form.Rule"
            type="textarea"
            placeholder="商品条码用“,”隔开,最多可添加5000个,若单品过多或需要全单品上传,请联系西联售后进行处理;若要全量上传单品请填写1"
          />
        </el-form-item>

        <el-form-item v-if="this.form.actTyp == 0">
          <el-select
            v-model="selectvalue"
            placeholder="请选择商品条码的一列"
            style="float: left"
            clearable
            @change="handleRule"
          >
            <el-option
              v-for="item in tableHeader"
              :key="item"
              :label="item"
              :value="item"
            />
          </el-select>
          <upload-excel-component
            style="float: left; margin-bottom: 10px"
            :on-success="handleSuccess"
            :before-upload="beforeUpload"
            title="上传文件只接受xls,xlsx类型,注:上传文件名不得超过15个字符"
          />
          <!-- <i class="el-icon-info"  style="margin-left: 5px;"></i> -->

          <el-button
            type="primary"
            plain
            size="small"
            style="margin-left: 20px"
          >
            <a
              href="http://file.pay.wuerp.com/%E8%A5%BF%E8%81%94%E5%8D%95%E5%93%81%E6%A8%A1%E6%9D%BF.xlsx"
              style="text-decoration: none"
            >
              下载商品模板
            </a>
          </el-button>

          <!-- <span style="color:red;margin-left: 20px;"></span> -->

          <el-table
            :data="tableData"
            border
            highlight-current-row
            style="width: 100%"
            height="120"
          >
            >
            <el-table-column
              v-for="item of tableHeader"
              :key="item"
              :prop="item"
              :label="item"
            />
          </el-table>
        </el-form-item>
        <br />
        <el-form-item
          v-if="this.form.actTyp == 1"
          label="账户分流比例"
          class="Rule"
        >
          <el-input
            v-model="rules_form.Rule"
            type="number"
            placeholder="订单比例用于支付分流,比例越大,支付越多"
            style="width: 312px"
            max="99"
            min="1"
            maxlength="1"
            show-word-limit
            @input="inputown($event)"
          />
        </el-form-item>
        <el-form-item v-if="this.form.actTyp == 1" label="账户上限金额">
          <el-input
            v-model="rules_form.LimitMny"
            type="number"
            placeholder="账户上限金额,单位/元"
            style="width: 312px"
            min="1"
            maxlength="1"
            show-word-limit
          />
        </el-form-item>

        <el-form-item v-if="this.form.actTyp == 1" label="金额上限周期">
          <el-radio-group v-model="rules_form.LimitCyl">
            <el-radio
              :label="0"
              title="当账户金额上限达到时,只要上限金额不变,则会保持不进账"
              >满额即停</el-radio
            >
            <el-radio
              :label="1"
              title="无论账户金额是否满额上限,只要上限金额不变,则会按日重新计算进账"
              >按日迭代</el-radio
            >
            <!-- <el-radio :label="2" title="无论账户金额是否满额上限,只要上限金额不变,则会按日重新计算进账">按月迭代</el-radio>-->
          </el-radio-group>
        </el-form-item>

        <el-form-item label="备注">
          <el-input v-model="rules_form.Remk" type="textarea" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary" @click="saveActivityCfg">确 定</el-button>
      </div>
    </el-dialog>

    <!--单品详情-->
    <el-dialog
      title="单品信息"
      :visible.sync="dialogdetailsVisible"
      width="35%"
    >
      <el-form :model="details_form" :inline="true" label-position="right">
        <el-form-item label="所填单品" style="width: 100%">
          <el-input
            v-model="details_form.goods"
            type="textarea"
            style="width: 400px"
            autosize
          />
          <span
            style="color: red"
            :class="{ divshow: !isdetial, divnone: isdetial }"
            >将文本框内的单品信息复制到活动配置单品条码中即可</span
          >
        </el-form-item>
      </el-form>
    </el-dialog>

    <!--活动详情-->
    <el-dialog
      title="活动详情"
      :visible.sync="dialogFormVisibleActDeial"
      width="60%"
      class="ActChannelCfgActDeial"
    >
      <el-form
        v-loading="ActDeialFormLoading"
        :model="ActDeialForm"
        :inline="true"
        label-position="right"
      >
        <div class="infocontentdiv">
          <div class="infocontent_line">
            <div class="infocontent_item_1">
              <span class="infocontent_item_name">企业：</span>
              <span class="infocontent_item_content">{{
                ActDeialForm.cpnIDStr
              }}</span>
            </div>
            <div class="infocontent_item_1">
              <span class="infocontent_item_name">前置机：</span>
              <span class="infocontent_item_content">{{
                ActDeialForm.actName
              }}</span>
            </div>
            <div class="infocontent_item_1">
              <span class="infocontent_item_name">操作人：</span>
              <span class="infocontent_item_content">{{
                ActDeialForm.operation
              }}</span>
            </div>
          </div>
          <div class="infocontent_line">
            <div class="infocontent_item_1">
              <span class="infocontent_item_name">提交时间：</span>
              <span class="infocontent_item_content">{{
                ActDeialForm.dtStr
              }}</span>
            </div>
            <div class="infocontent_item_1">
              <span class="infocontent_item_name">开始日期：</span>
              <span class="infocontent_item_content">{{
                ActDeialForm.actStdtStr
              }}</span>
            </div>
            <div class="infocontent_item_1">
              <span class="infocontent_item_name">结束日期：</span>
              <span class="infocontent_item_content">{{
                ActDeialForm.actEdtStr
              }}</span>
            </div>
          </div>
          <div class="infocontent_line">
            <div class="infocontent_item_1">
              <span class="infocontent_item_name">主/次事件：</span>
              <span class="infocontent_item_content">{{
                ActDeialForm.prtActId == "" || ActDeialForm.prtActId == null
                  ? "主事件"
                  : "次事件"
              }}</span>
            </div>
          </div>
          <div class="infocontent_line">
            <div class="infocontent_item_1">
              <span class="infocontent_item_name">主/单账户列表</span>
              <span class="infocontent_item_content">{{
                ActDeialForm.payTyp
              }}</span>
            </div>
          </div>
          <div>
            <el-table
              :data="ActDeialForm.cpnActCfgInfoRuleDTOs"
              style="width: 100%"
              fit
              :span-method="objectSpanMethod"
            >
              <el-table-column label="账户类型" align="left" min-width="100px">
                <template slot-scope="{ row }">
                  <span>{{ row.typ == 0 ? "主账户" : "单品账户" }}</span>
                </template>
              </el-table-column>
              <el-table-column label="账户名称" align="left" min-width="400px">
                <template slot-scope="{ row }">
                  <span
                    >{{ row.payTypStr }}：{{ row.alisNme }}[{{ row.act }}]</span
                  >
                </template>
              </el-table-column>
              <el-table-column label="支付渠道" align="left" min-width="200px">
                <template slot-scope="{ row }">
                  <span>{{ row.payChannelStr }}</span>
                </template>
              </el-table-column>
              <el-table-column label="单品条码" align="left" width="100px">
                <template slot-scope="{ row }">
                  <template v-if="row.typ == 0">
                    <el-input
                      value="—"
                      class="edit-input"
                      size="small"
                      style="width: 70px"
                      :disabled="true"
                    />
                  </template>
                  <template v-else>
                    <el-button
                      v-if="row.flieUrl == '' || row.flieUrl == null"
                      type="primary"
                      size="mini"
                      @click="showGoods(row)"
                      >查看单品</el-button
                    >
                    <a
                      v-else
                      :href="row.flieUrl"
                      target="_blank"
                      style="color: #409eff; margin-left: 14px"
                      title="点击下载当前账户单品条码表格"
                      type="primary"
                      size="mini"
                      >下载表格</a
                    >
                  </template>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
      </el-form>
    </el-dialog>

    <!--弹出层 end-->
  </div>
</template>

<script>
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
import {
  AjaxToken,
  TipConfirm,
  AjaxTokenNotasync,
  AjaxUpload,
} from "@/api/common";
import { SelectAjax } from "@/api/common";
import { Jurisdiction } from "@/api/common";
import sessionStorage from "@/api/Storage";
import "url-search-params-polyfill"; // 兼容IE，否则无法识别URLSearchParams
import UploadExcelComponent from "@/components/UploadExcel/index.vue";
import countTo from "vue-count-to";
import PinYinMatch from "pinyin-match";
export default {
  name: "ActChannelCfgGood",
  components: {
    Pagination,
    UploadExcelComponent,
    countTo,
  },
  data() {
    return {
      active: 0,
      divid: 0,
      actTypdisabled: false,
      subisabled: false,
      switch: false,
      tag: true,
      tableData: [],
      tableHeader: [],
      orgoptions: [],
      selectvalue: "",
      switchvalue: false,
      isdetial: false,
      cpnoptions: [],
      cpnorgLoading: true,
      cpnPyMchinRctListoptions: [],
      trialSttoptions: [],
      paytypeoptions: [],
      CpnActCfgInfos: [],
      paytychanneloptions: [],
      multipleSelectionAct: [],
      SecmultipleSelectionAct: [],
      rules_formdata: [],
      cpnActCfgInfoActRlue: [],
      isnext: true,
      logincpnid: "",
      multipleSelection: [],
      selectOrgs: [],
      formLabelWidth: "120px",
      ActChannelCfgData: null,
      ActChannelCfgDataSub: null,
      ActivityactData: null,
      allmony: 0,
      listQuery: {
        title: "",
        total: 0,
        page: 1,
        limit: 10,
      },
      listLoading: true,
      listLoadingsub: true,
      dialogFormVisible: false,
      dialogdetailsVisible: false,
      dialoginnerVisible: false,
      dialogFormVisibleSub: false,
      dialogFormVisibleActDeial: false,
      ActDeialFormLoading: false,
      dialogStatus: "",
      uploadid: "",
      filedata: [],
      textMap: {
        update: "修改",
        create: "添加",
      },
      actTypoptions: [
        {
          value: 0,
          label: "金额",
        },
        {
          value: 1,
          label: "笔数",
        },
      ],
      form: {
        actID: "",
        iD: "",
        cpnID: "",
        orgID: "",
        pyMchinID: "",
        actStdt: "",
        actEdt: "",
        dt: "",
        operation: "",
        actName: "",
        actTyp: 0,
        rulTyp: 1,
        isEnable: "",
        isDeleted: "",
        IsAdd: true,
        paytyp: "",
        paychannel: "",
        prtActId: "",
        PrActID: "",
        trialStt: 0,
      },
      details_form: {
        iD: "",
        cpnID: "",
        orgID: "",
        pyMchinID: "",
        actStdt: "",
        actEdt: "",
        dt: "",
        operation: "",
        goods: "",
        actName: "",
        actTyp: 0,
        isEnable: "",
        isDeleted: "",
      },
      rules_form: {
        Rule: "",
        Remk: "",
        ID: "",
        LimitMny: 0,
        LimitCyl: 0,
        PayChannelStr: "",
        PayChannel: "",
        PayTyp: "",
        PayTypStr: "",
        AlisNme: "",
      },
      SubForm: {
        actid: "",
        trialStt: 0,
        trialSttStr: "",
        enablStt: 0,
        enablSttStr: "",
        actEdtStr: "",
        actStdtStr: "",
      },
      ActDeialForm: {},
      listQueryAct: {
        title: "",
        total: 0,
        page: 1,
        limit: 10,
      },
    };
  },

  // 初始化
  created() {
    debugger;
    var userinfo = JSON.parse(sessionStorage.getItem("userinfo"));
    this.logincpnid = userinfo.cpnId;
    this.fetchData();
    backstage.GetPayTypeList(this);
    backstage.GetPyChannelSelectListItems(this);
    backstage.GetEnum_TrialStt(this, false);
    backstage.GeCpntListItems(this);
  },
  mounted() {
    this.showMsg = this.debounce(this.showMsg, 500, false);
  },
  methods: {
    cpnmatch(val) {
      if (val) {
        let result = [];
        this.cpnoptions.forEach((item) => {
          let matchRes = PinYinMatch.match(item.label, val);
          if (matchRes) {
            result.push(item);
          }
        });
        this.cpnoptions = result;
      } else {
        this.cpnid = "";
        this.cpnoptions = backstage.GeCpntListItems(this);
      }
    },
    dateCheck(item) {
      function timestampToTime(timestamp) {
        if ((timestamp + "").length == 10) {
          var date = new Date(timestamp * 1000);
        }
        if ((timestamp + "").length == 13) {
          var date = new Date(timestamp);
        }
        var Y = (date.getFullYear() + "").padStart(2, 0) + "-";
        var M = Number((date.getMonth() + "").padStart(2, 0)) + 1 + "-";
        var D = (date.getDate() + "").padStart(2, 0) + " ";
        return Y + M + D;
      }
      if (item) {
        let time1 = new Date(timestampToTime(new Date().getTime())).getTime();
        let time2 = new Date(
          timestampToTime(new Date(item).getTime())
        ).getTime();

        // 三天内要结束的活动
        if (time2 - time1 <= 172800000 && time2 - time1 >= 0) {
          return 1;
        } else if (time2 - time1 < 0) {
          // 已经结束的活动
          return 0;
        } else {
          // 超过三天要开始的活动
          return -1;
        }
      } else {
        // 没有结束日期则为永久生效
        return -1;
      }
    },
    // 展示活动详情
    ShowActDetial: function (row) {
      var params2 = new URLSearchParams();
      params2.append("ActID", row.id);
      this.dialogFormVisibleActDeial = true;
      this.ActDeialFormLoading = true;
      backstage.GetActChannelCfgBllLstByActId(this, params2);
    },
    showGoods: function (row) {
      this.isdetial = true;
      this.details_form.goods = row.rule;
      this.dialogdetailsVisible = true;
    },
    // 活动配置
    ActivityCfgClick(row) {
      this.isdetial = false;
      for (var i = 0; i < this.cpnActCfgInfoActRlue.length; i++) {
        if (row.id == this.cpnActCfgInfoActRlue[i].id) {
          this.uploadid = row.id;
          this.rules_form.ID = this.cpnActCfgInfoActRlue[i].id;
          this.rules_form.Rule = this.cpnActCfgInfoActRlue[i].rule;
          this.rules_form.Remk = this.cpnActCfgInfoActRlue[i].remk;
          this.rules_form.LimitMny = this.cpnActCfgInfoActRlue[i].limitMny;
          this.rules_form.LimitCyl = this.cpnActCfgInfoActRlue[i].limitCyl;
        }
      }
      this.dialoginnerVisible = true;
    },
    // 活动配置
    ActivityCfgC(row) {
      for (var i = 0; i < this.cpnActCfgInfoActRlue.length; i++) {
        if (row.id == this.cpnActCfgInfoActRlue[i].id) {
          this.uploadid = row.id;
          this.rules_form.ID = this.cpnActCfgInfoActRlue[i].id;
          this.rules_form.Rule = this.cpnActCfgInfoActRlue[i].rule;
          this.rules_form.Remk = this.cpnActCfgInfoActRlue[i].remk;
          this.rules_form.LimitMny = this.cpnActCfgInfoActRlue[i].limitMny;
          this.rules_form.LimitCyl = this.cpnActCfgInfoActRlue[i].limitCyl;
        }
      }
    },
    // 保存活动配置
    saveActivityCfg() {
      if (this.rules_form.Rule == "") {
        this.$message({
          message: "商品条码不能为空",
          type: "error",
          duration: "3000",
        });
        return false;
      }
      if (this.tableData.length > 0 && this.selectvalue == "") {
        this.$message({
          message: "请选择商品条码所在列",
          type: "error",
          duration: "3000",
        });
        return false;
      }

      for (var i = 0; i < this.cpnActCfgInfoActRlue.length; i++) {
        if (this.rules_form.ID == this.cpnActCfgInfoActRlue[i].id) {
          this.cpnActCfgInfoActRlue[i].rule = this.rules_form.Rule;
          this.cpnActCfgInfoActRlue[i].remk = this.rules_form.Remk;
          this.cpnActCfgInfoActRlue[i].limitMny = this.rules_form.LimitMny;
          this.cpnActCfgInfoActRlue[i].limitCyl = this.rules_form.LimitCyl;
        }
      }
      this.uploadid = "";
      this.selectvalue = "";
      this.dialoginnerVisible = false;
      this.tableData = []; // 清空上传文件表格内容
      this.tableHeader = []; // 清空上传文件表格表头
    },
    // 子事件
    SubClick(row) {
      this.SubForm.actid = row.id;
      this.SubForm.trialStt = row.trialStt;
      this.SubForm.trialSttStr = row.trialSttStr;
      this.SubForm.enablStt = row.enablStt;
      this.SubForm.enablSttStr = row.enablSttStr;
      this.SubForm.actEdtStr = row.actEdtStr;
      this.SubForm.actStdtStr = row.actStdtStr;
      this.subisabled = true;
      this.actTypdisabled = true;
      this.active = 0;
      this.divid = 0;
      this.form.trialStt = 0;
      this.form.iD = row.id;
      this.form.actID = row.id;

      this.form.cpnID = row.cpnID;
      this.form.pyMchinID = row.pyMchinID;
      this.form.actStdt = row.actStdt;
      this.form.actEdt = row.actEdt;
      this.form.dt = row.dt;
      this.form.operation = row.operation;
      this.form.actName = row.actName;
      this.form.actTyp = row.actTyp;
      this.form.isEnable = row.isEnable;
      this.form.isDeleted = row.isDeleted;
      this.form.IsAdd = false;
      this.selectOrgs = [];
      this.SecmultipleSelectionAct = [];
      this.ActChannelCfgDataSub = [];
      this.listLoadingsub = true;
      backstage.GeCpnPyMchinRctOrgs(this);
      backstage.GeCpntListItems(this);
      backstage.GeCpnPyMchinRctListItems(this);
      backstage.GetCpnOrgList(this, row.cpnID);
      // 获取所有已选
      var params = new URLSearchParams();
      params.append(
        "Parms",
        '{"page":' +
          this.listQueryAct.page +
          ',"rows":' +
          this.listQueryAct.limit +
          "}"
      );
      params.append("CpnID", this.form.cpnID);
      params.append("IsAdd", this.form.IsAdd);
      params.append("ActID", this.form.actID);
      params.append("PyChnlID", this.form.paychannel);
      params.append("PyTypID", this.form.paytyp);

      params.append("IsAll", true);
      backstage.GetCpnActCfgInfoAct2(this, params);
      this.fetchDataAct();
      this.feachDataActChannelCfgLstSub();
      this.dialogFormVisibleSub = true;
    },
    ruleInput(e, row) {
      // 赋值其他相同账户比列
      this.cpnActCfgInfoActRlue.forEach((x) => {
        if (x.act == row.act) {
          x.rule = 0;
        }
      });
      var allrule = 0;
      row.rule = e == "" ? "" : e;
      if (row.rule != "" && parseInt(e) < 0) {
        this.$message({
          message: "分流比列不能小于0",
          type: "warning",
        });
        row.rule = 0;
        return;
      }
      this.cpnActCfgInfoActRlue.forEach((x) => {
        if (x.typ == 1) {
          allrule += parseInt(x.rule);
        }
      });
      if (allrule > 100) {
        this.$message({
          message: "单品账户总比列不能大于100,请重试",
          type: "warning",
        });
        row.rule = 0;
        return;
      } else {
        this.cpnActCfgInfoActRlue.forEach((x) => {
          if (x.typ == 0) {
            if (!isNaN(allrule)) {
              x.rule = 100 - allrule;
            } else {
              x.rule = 100;
            }
          }
        });
      }
      // 赋值其他相同账户比列
      this.cpnActCfgInfoActRlue.forEach((x) => {
        if (row.rule == "") {
          if (x.act == row.act) {
            x.rule = "";
          }
        } else {
          if (x.act == row.act) {
            x.rule = row.rule;
          }
        }
      });
    },
    limitMnyeInput(e, row) {
      // 计算总上限
      this.allmony = 0;
      row.limitMny = e == "" ? "" : e;
      if (row.limitMny != "" && parseInt(e) < 0) {
        this.$message({
          message: "上限不能小于0",
          type: "warning",
        });
        row.limitMny = 0;
        return;
      }
      this.cpnActCfgInfoActRlue.forEach((x) => {
        if (x.typ == 1) {
          this.allmony += parseInt(x.limitMny);
        }
      });
      if (isNaN(this.allmony)) {
        this.allmony = 0;
      }
    },
    inputown(e, row) {
      if (e > 99) {
        row.rule = 1;
      }
    },
    // 跨行处理
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 0 || columnIndex >= 2) {
        // 账户类型跨行
        if (columnIndex == 0) {
          if (row.typspan > 0) {
            return {
              rowspan: row.typspan,
              colspan: 1,
            };
          } else {
            return {
              rowspan: 0,
              colspan: 0,
            };
          }
        }

        // 比列 上限金额跨行
        if (columnIndex > 2) {
          if (row.typ == 0) {
            if (row.typspan > 0) {
              return {
                rowspan: row.typspan,
                colspan: 1,
              };
            } else {
              return {
                rowspan: 0,
                colspan: 0,
              };
            }
          }
        }
        // 比列 上限金额跨行 结束
      }
    },
    handleSelectionChangeAct(val) {
      /*
       * 获取某个元素下标
       * arr: 传入的数组
       * obj: 需要获取下标的元素
       * */

      // 第二种方法有问题
      // function getIndex(arr, obj) {
      //   var i = arr.length;
      //   while (i--) {
      //     if (arr[i] === obj) {
      //       return i;
      //     }
      //   }
      //   return -1;
      // }

      // var box = []
      // var indexBox = []

      // for (var i = 0; i < val.length; i++) {
      //   // 有多少个val就有多少个二维数组
      //   box[i] = []

      // }

      // this.CpnActCfgInfos.forEach((item, index) => {

      //   for (var i = 0; i < val.length; i++) {
      //     // 寻找选中内容中支付渠道相同的项，并获取下标
      //     if (item.payTyp == val[i].payTyp) {

      //       box[i].push(index)
      //     }

      //   }

      // })

      // if (box.length > 0) {
      //   // 让this.CpnActCfgInfos中选中内容渠道相同的其他选项都变为只读
      //   for (var i = 0; i < box.length; i++) {
      //        // 获取选择内容在this.CpnActCfgInfos对应下标
      //     var selectIndex = getIndex(this.CpnActCfgInfos, val[i])

      //     if (selectIndex !== -1) {
      //       // console.log('selectIndex: ', selectIndex);
      //       for (var j = 0; j < box[i].length; j++) {

      //         if ((box[i])[j] !== selectIndex) {
      //           this.CpnActCfgInfos[(box[i])[j]].isRead = true;
      //         }

      //       }
      //     }

      //   }
      // }

      // console.log('this.CpnActCfgInfos: ', this.CpnActCfgInfos);

      if (val.length >= 2) {
        for (var i = 0; i < val.length; i++) {
          for (var j = i + 1; j < val.length; j++) {
            if (val[i].payTyp == val[j].payTyp) {
              this.$refs.multipleTable2.toggleRowSelection(val[j], false);

              val.splice(j, 1);

              if (this.tag == false) {
                return;
              }
              this.showMsg();
            }
          }
        }
      }

      val.forEach((element) => {
        var isadd = false;
        this.SecmultipleSelectionAct.forEach((a) => {
          if (element.id == a.id) {
            isadd = true;
          }
        });
        if (!isadd) {
          this.SecmultipleSelectionAct.push(element);
        }
      });
      var notacts = [];
      this.CpnActCfgInfos.forEach((cacf) => {
        var isadd = false;
        val.forEach((vale) => {
          if (vale.id == cacf.id) {
            isadd = true;
          }
        });
        if (!isadd) {
          notacts.push(cacf);
        }
      });
      this.multipleSelectionAct = val;
      var newSecmultipleSelectionAct = [];

      this.SecmultipleSelectionAct.forEach((a) => {
        var isadd = false;
        notacts.forEach((b) => {
          if (a.id == b.id) {
            isadd = true;
          }
        });
        if (!isadd) {
          newSecmultipleSelectionAct.push(a);
        }
      });

      // console.log('newSecmultipleSelectionAct: ', newSecmultipleSelectionAct);

      // 修复翻页后无法检测支付方式重复的问题
      for (var i = 0; i < newSecmultipleSelectionAct.length; i++) {
        for (var j = i + 1; j < newSecmultipleSelectionAct.length; j++) {
          if (
            newSecmultipleSelectionAct[i].payTyp ==
            newSecmultipleSelectionAct[j].payTyp
          ) {
            this.$refs.multipleTable2.toggleRowSelection(
              newSecmultipleSelectionAct[j],
              false
            );
            newSecmultipleSelectionAct.splice(j, 1);
            if (this.tag == false) {
              return;
            }
            this.showMsg();
          }
        }
      }

      this.SecmultipleSelectionAct = newSecmultipleSelectionAct;
    },
    clearallact() {
      this.SecmultipleSelectionAct = [];
      this.$refs.multipleTable2.clearSelection();
      // this.CpnActCfgInfos.forEach(item=>{
      //   item.isRead=false;
      // })
      this.switch = false;
    },
    getRowKeys(row) {
      return row.id;
    },
    /**
     * 防反跳。fn函数在最后一次调用时刻的delay毫秒之后执行！
     * @param fn 执行函数
     * @param delay 时间间隔
     * @param isImmediate 为true，debounce会在delay时间间隔的开始时立即调用这个函数
     * @returns {Function}
     */

    debounce(fn, delay, isImmediate) {
      var timer = null; // 初始化timer，作为计时清除依据
      return function () {
        var context = this; // 获取函数所在作用域this
        var args = arguments; // 取得传入参数
        clearTimeout(timer);
        if (isImmediate && timer === null) {
          // 时间间隔外立即执行
          fn.apply(context, args);
          timer = 0;
          return;
        }
        timer = setTimeout(function () {
          fn.apply(context, args);
          timer = null;
        }, delay);
      };
    },
    showMsg() {
      this.$message({
        showClose: true,
        message: "同一支付方式不允许出现在两个不同的账户",
        type: "error",
        duration: 3000,
      });
    },
    onTableSelect(selection, row) {},
    selectAll(selection) {
      // console.log('selection: ', selection);
      this.switch = !this.switch;
      this.tag = !this.tag;
      if (this.switch == false) {
        this.clearallact();
      }
    },
    checkSelect(row, index) {
      if (row.isRead == true) {
        return false;
      }
      return true;
    },
    act_close(item) {
      //  原代码
      var oldact = this.multipleSelectionAct;

      this.$refs.multipleTable2.clearSelection();
      oldact.forEach((element) => {
        if (element.id != item.id) {
          this.$refs.multipleTable2.toggleRowSelection(element);
        }
      });
    },
    prv() {
      this.active = this.active - 1;
      this.divid = this.active;
      this.isnext = true;
    },
    next() {
      // if(this.rules_form.Rule==""&&this.)
      if (this.form.cpnID == "" || this.form.cpnID == undefined) {
        this.$message({
          showClose: true,
          message: "请选择企业",
          type: "error",
        });
        return;
      } else if (
        !backstage.compareTime(
          new Date(this.form.actStdt).toLocaleDateString(),
          new Date(this.form.actEdt).toLocaleDateString()
        )
      ) {
        this.$message({
          showClose: true,
          message: "开始日期不能大于结束日期",
          type: "error",
        });
        return;
      } else if (this.form.pyMchinID == "") {
        this.$message({
          showClose: true,
          message: "请选择关联前置机",
          type: "error",
        });
        return;
      }
      if (this.active == 1) {
        if (this.SecmultipleSelectionAct.length <= 0) {
          this.$message({
            showClose: true,
            message: "请至少选择一个账户",
            type: "error",
          });
          return;
        } else {
          var params = new URLSearchParams();
          params.append(
            "selectActs",
            JSON.stringify(this.SecmultipleSelectionAct)
          );
          params.append("PyMchinId", this.form.pyMchinID);
          params.append("IsAdd", false);
          params.append("ActID", this.form.actID);
          params.append("ActTyp", 0);
          backstage.CpnActCfgInfoActRlue(this, params);
          if (this.active++ > 3) {
            this.active = 0;
          }
          this.divid = this.active;
        }
      } else {
        if (this.active++ > 3) {
          this.active = 0;
        }
        this.divid = this.active;
      }
      if (this.divid == 3 && this.rules_form.Rule == "") {
        // console.log('==================')
        this.$message({
          message: "商品条码不能为空",
          type: "error",
          duration: "3000",
        });
        this.divid = 2;
        this.active = 2;
      }
    },
    beforeUpload(file) {
      const isLt1M = file.size / 1024 / 1024 < 1;
      if (isLt1M) {
        return true;
      }
      this.$message({
        message: "请不要上传大于1m的文件",
        type: "warning",
      });
      return false;
    },
    handleFilterAct(row) {
      this.fetchDataAct();
    },
    handleSuccess({ results, header, rawFile }) {
      this.tableData = results;
      this.tableHeader = header;
      this.orgshow = true;
      const params = new FormData();
      params.append("file", rawFile);
      params.append("CpnID", this.form.cpnID);
      params.append("PyMchinID", this.form.pyMchinID);
      params.append("uploadid", this.uploadid);
      backstage.UpFile(this, params);
    },
    fetchDataAct() {
      var params = new URLSearchParams();
      params.append(
        "Parms",
        '{"page":' +
          this.listQueryAct.page +
          ',"rows":' +
          this.listQueryAct.limit +
          "}"
      );
      params.append("CpnID", this.form.cpnID);
      params.append("IsAdd", this.form.IsAdd);
      params.append("ActID", this.form.actID);
      params.append("PyChnlID", this.form.paychannel);
      params.append("PyTypID", this.form.paytyp);
      params.append("PyMchinId", this.form.pyMchinID);
      params.append("PrActID", this.form.PrActID);
      params.append("ActTyp", 0);
      backstage.GetCpnActCfgInfoAct(this, params);
      this.switch = false;

      // 第二种方案有问题
      // console.log(' this.SecmultipleSelectionAct: ',  this.SecmultipleSelectionAct);
      // this.SecmultipleSelectionAct.forEach(item=>{
      // debugger
      //   for (var i = 0; i < this.CpnActCfgInfos.length; i++){
      //       if(item.payTyp==this.CpnActCfgInfos[i].payTyp){
      //         this.CpnActCfgInfos[i].isRead=true;
      //       }
      //   }
      // })
    },

    feachDataActChannelCfgLstSub() {
      var params = new URLSearchParams();
      params.append(
        "Parms",
        '{"page":' +
          this.listQueryAct.page +
          ',"rows":' +
          this.listQueryAct.limit +
          "}"
      );
      var user = JSON.parse(sessionStorage.getItem("userinfo"));
      params.append(
        "CpnID",
        this.form.cpnID == "" ? user.cpnId : this.form.cpnID
      );
      params.append("ActTyp", 0);
      params.append("IsAll", true);
      params.append("PrtActId", this.SubForm.actid);
      backstage.GetActChannelCfgLstSub(this, params);
    },
    // 把excle的商品条码赋值到单品条码的文本域中(下拉选项的change事件)
    handleRule() {
      if (this.selectvalue != "") {
        var codedata = "";
        for (var item in this.tableData) {
          var itemvalue = this.tableData[item];
          for (var obj in itemvalue) {
            if (obj == this.selectvalue) {
              try {
                codedata += itemvalue[obj].replace(/(^\s*)|(\s*$)/g, "") + ",";
              } catch {
                codedata += itemvalue[obj] + ",";
              }
            }
          }
        }
        this.details_form.goods = codedata.substring(
          0,
          codedata.lastIndexOf(",")
        );

        this.rules_form.Rule = this.details_form.goods;
        // this.dialogdetailsVisible = true;
      }
      // this.rules_form.Rule += codedata.substring(0, codedata.lastIndexOf(","));
    },
    // 弹层关闭
    handleClose() {},
    inputown(e) {
      if (e > 99) {
        this.rules_form.Rule = 1;
      }
    },
    EnableIsEmrgncy(e, row) {
      for (var i = 0; i < this.rules_formdata.length; i++) {
        if (row.id == this.rules_formdata[i].ID) {
          this.rules_formdata[i].isEnable = e;
        }
      }
    },
    // 权限
    Jurisdiction(moduleActionName) {
      return Jurisdiction(moduleActionName, this);
    },
    // 多选
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    // 多选赋值
    toggleSelection(rows) {
      if (rows) {
        rows.forEach((row) => {
          this.$refs.multipleTable2.toggleRowSelection(row);
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable2.clearSelection();
        this.$refs.multipleTable.toggleRowSelection(row);
      }
    },
    // 搜索
    handleFilter(typ) {
      if (typ == 2) {
        this.listQuery.page = 1;
        this.listQuery.title = "";
        this.form = {
          cpnID: "",
        };
        this.fetchData();
      } else {
        this.listQuery.page = 1;
        this.fetchData();
      }
    },
    // 新增
    handleCreate() {
      this.uploadid = "";
      this.filedata = [];
      this.active = 0;
      this.divid = 0;
      this.dialogStatus = "create";
      this.dialogFormVisible = true;
      this.form = {
        iD: "",
        cpnID: this.form.cpnID,
        orgID: "",
        pyMchinID: "",
        actStdt: "",
        actEdt: "",
        dt: "",
        operation: "",
        actName: "",
        actTyp: 0,
        rulTyp: 1,
        isEnable: "",
        isDeleted: "",
        actID: "",
        IsAdd: true,
        paytyp: "",
        paychannel: "",
        prtActId: "",
      };
      if (this.logincpnid != "system") {
        this.form.cpnID = this.logincpnid;
        this.form.orgID = "";
        this.form.pyMchinID = "";
        this.SecmultipleSelectionAct = [];
        this.selectOrgs = [];
        backstage.GetCpnOrgList(this, this.logincpnid);
        backstage.GeCpnPyMchinRctListItems(this);
      } else {
        this.form.actID = "";
        this.selectOrgs = [];
        this.SecmultipleSelectionAct = [];
        backstage.GeCpntListItems(this);
        backstage.GeCpnPyMchinRctListItems(this);
      }

      this.actTypdisabled = false;
      this.subisabled = false;
      this.SubForm.actid = "";
      this.form.trialStt = 0;
    },
    // 编辑
    handleClick(row) {
      if (row.trialStt == 1 && row.enablStt != 2) {
        this.$message({
          showClose: true,
          message:
            "只有待审核或审核拒绝的的活动可以编辑,审核通过的活动不可修改",
          type: "info",
        });
        return;
      }
      this.actTypdisabled = true;
      this.subisabled = false;
      this.active = 0;
      this.divid = 0;
      this.form.iD = row.id;
      this.form.actID = row.id;
      this.form.cpnID = row.cpnID;
      this.form.pyMchinID = row.pyMchinID;
      this.form.actStdt = row.actStdt;
      this.form.actEdt = row.actEdt;
      this.form.dt = row.dt;
      this.form.operation = row.operation;
      this.form.actName = row.actName;
      this.form.actTyp = row.actTyp;
      this.form.rulTyp = row.rulTyp;
      this.SubForm.actid = "";
      this.form.isEnable = row.isEnable;
      this.form.isDeleted = row.isDeleted;
      this.form.trialStt = row.trialStt;
      this.form.IsAdd = false;
      this.dialogStatus = "update";
      this.dialogFormVisible = true;
      this.selectOrgs = [];
      this.SecmultipleSelectionAct = [];
      this.CpnActCfgInfos = [];
      backstage.GeCpntListItems(this);
      backstage.GetCpnOrgList(this, row.cpnID);
      backstage.GeCpnPyMchinRctOrgs(this);
      backstage.GeCpnPyMchinRctListItems(this);
      this.loaddata();
    },
    // 加载已选数据
    loaddata() {
      // 获取所有已选
      var params = new URLSearchParams();
      params.append(
        "Parms",
        '{"page":' +
          this.listQueryAct.page +
          ',"rows":' +
          this.listQueryAct.limit +
          "}"
      );
      params.append("CpnID", this.form.cpnID);
      params.append("IsAdd", this.form.IsAdd);
      params.append("ActID", this.form.actID);
      params.append("PyChnlID", this.form.paychannel);
      params.append("PyTypID", this.form.paytyp);
      params.append("IsAll", true);
      params.append("ActTyp", 0);
      backstage.GetCpnActCfgInfoAct2(this, params);
      this.fetchDataAct();
    },
    // 新增活动子事件
    handleCreateSub() {
      this.uploadid = "";
      this.filedata = [];
      this.active = 0;
      this.divid = 0;
      this.form.PrActID = this.form.actID;
      this.form.actID = "";

      this.form.iD = "";
      this.form.trialStt == 0;
      this.dialogStatus = "create";
      this.dialogFormVisible = true;
      this.fetchDataAct();
    },
    // 编辑活动子事件
    handleClickSub(row) {
      if (row.trialStt == 1 && row.enablStt != 2) {
        this.$message({
          showClose: true,
          message:
            "只有待审核或审核拒绝的的活动可以编辑,审核通过的活动不可修改",
          type: "info",
        });
        return;
      }
      this.actTypdisabled = true;
      this.subisabled = true;
      this.active = 0;
      this.divid = 0;
      this.form.iD = row.id;
      this.form.trialStt = row.trialStt;
      this.form.actID = row.id;
      this.form.cpnID = row.cpnID;
      this.form.pyMchinID = row.pyMchinID;
      this.form.actStdt = row.actStdt;
      this.form.actEdt = row.actEdt;
      this.form.dt = row.dt;
      this.form.operation = row.operation;
      this.form.actName = row.actName;
      this.form.actTyp = row.actTyp;
      this.form.isEnable = row.isEnable;
      this.form.isDeleted = row.isDeleted;
      this.form.prtActId = row.prtActId;
      this.form.IsAdd = false;
      this.dialogStatus = "update";
      this.dialogFormVisible = true;
      this.selectOrgs = [];
      this.SecmultipleSelectionAct = [];
      this.CpnActCfgInfos = [];
      backstage.GeCpnPyMchinRctOrgs(this);
      backstage.GeCpntListItems(this);
      backstage.GeCpnPyMchinRctListItems(this);
      backstage.GetCpnOrgList(this, row.cpnID);
      // 获取所有已选
      var params = new URLSearchParams();
      params.append(
        "Parms",
        '{"page":' +
          this.listQueryAct.page +
          ',"rows":' +
          this.listQueryAct.limit +
          "}"
      );
      params.append("CpnID", this.form.cpnID);
      params.append("IsAdd", this.form.IsAdd);
      params.append("ActID", this.form.actID);
      params.append("PyChnlID", this.form.paychannel);
      params.append("PyTypID", this.form.paytyp);
      params.append("IsAll", true);
      backstage.GetCpnActCfgInfoAct2(this, params);
      this.fetchDataAct();
    },
    cancel() {
      this.dialoginnerVisible = false;
      this.tableData = [];
      this.tableHeader = [];
      this.selectvalue = "";
    },
    // 保存活动
    saveForm() {
      this.rules_formdata = [];
      if (this.form.actName == "") {
        this.$message({
          showClose: true,
          message: "请输入活动名称",
          type: "error",
        });
      } else if (
        !backstage.compareTime(
          new Date(this.form.actStdt).toLocaleDateString(),
          new Date(this.form.actEdt).toLocaleDateString()
        )
      ) {
        this.$message({
          showClose: true,
          message: "开始日期不能大于结束日期",
          type: "error",
        });
      } else if (this.form.pyMchinID == "") {
        this.$message({
          showClose: true,
          message: "请选择关联前置机",
          type: "error",
        });
      } else {
        this.cpnActCfgInfoActRlue.forEach((element) => {
          if (element.typ == 1) {
            this.rules_formdata.push({
              ID: element.id,
              Rule: element.rule,
              Remk: element.rmrk,
              LimitMny: element.limitMny,
              LimitCyl: this.rules_form.LimitCyl,
              IsEnable: true,
              PayChannel: element.payChannel,
              PayTyp: element.payTyp,
              Act: element.act,
            });
          }
        });
        var params = new URLSearchParams();
        params.append("ActID", this.form.actID);
        params.append("CpnID", this.form.cpnID);
        params.append("PyMchinID", this.form.pyMchinID);
        params.append(
          "ActStdt",
          this.form.actStdt == ""
            ? ""
            : new Date(this.form.actStdt).toLocaleDateString()
        );
        params.append(
          "ActEdt",
          this.form.actEdt == ""
            ? ""
            : new Date(this.form.actEdt).toLocaleDateString()
        );
        params.append("ActName", this.form.actName);
        params.append("ActTyp", 0);
        params.append("RulTyp", this.form.rulTyp);
        params.append("selectActs", JSON.stringify(this.rules_formdata));
        params.append("PrtActId", this.SubForm.actid);
        params.append("Filedata", JSON.stringify(this.filedata));

        if (this.form.iD != "") {
          this.$prompt("", "请输入修改原因", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
          })
            .then(({ value }) => {
              this.$confirm(
                "活动提交后,无法进行修改编辑,确认提交吗？",
                "提示",
                {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
                }
              )
                .then((a) => {
                  const loading = this.$loading({
                    lock: true,
                    text: "Loading",
                    spinner: "filter-container",
                    background: "rgba(0, 0, 0, 0.7)",
                  });
                  params.append("operation", value);
                  backstage.SaveActChannelCfg(this, params, loading);
                })
                .catch(() => {
                  this.$message({
                    type: "info",
                    message: "已取消",
                  });
                  this.listLoading = false;
                  this.listLoadingsub = false;
                });
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "取消",
              });
            });
        } else {
          this.$confirm("活动提交后,无法进行修改编辑,确认提交吗？", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
            .then((a) => {
              this.listLoading = true;
              this.listLoadingsub = true;
              const loading = this.$loading({
                lock: true,
                text: "Loading",
                spinner: "filter-container",
                background: "rgba(0, 0, 0, 0.7)",
              });
              backstage.SaveActChannelCfg(this, params, loading);
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "已取消",
              });
              this.listLoadingsub = false;
              this.listLoading = false;
            });
        }
      }
      this.tableData = [];
    },
    CpnselectFn(e) {
      this.form.cpnID = e;
      this.form.orgID = "";
      this.form.pyMchinID = "";
      this.SecmultipleSelectionAct = [];
      backstage.GetCpnOrgList(this, e);
      backstage.GeCpnPyMchinRctListItems(this);
      this.loaddata();
    },
    OrgselectFn(e) {
      // debugger;
      this.form.orgID = e;
      this.SecmultipleSelectionAct = [];
      this.form.pyMchinID = "";
      backstage.GeCpnPyMchinRctListItems(this);
      this.loaddata();
    },
    PyMchselectFn(e) {
      this.form.pyMchinID = e;
      this.selectOrgs = [];
      this.form.actName = event.target.innerText;
      this.SecmultipleSelectionAct = [];
      backstage.GeCpnPyMchinRctOrgs(this);
      this.loaddata();
    },
    // 删除
    deleteClick(row) {
      debugger;
      var multis = [];
      var params = new URLSearchParams();
      if (row == undefined || row == "") {
        var arr = this.multipleSelection;
        if (arr == undefined || arr.length <= 0) {
          this.$message({
            showClose: true,
            message: "请至少选中一行",
            type: "error",
          });
          this.listLoading = false;
          return;
        } else {
          for (var i = 0; i < arr.length; i++) {
            multis.push(arr[i].id);
          }
          params.append("delds", JSON.stringify(multis));
        }
      } else {
        multis.push(row.id);
        params.append("delds", JSON.stringify(multis));
      }
      this.$confirm("确认删除吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "error",
      })
        .then((a) => {
          this.listLoading = true;
          this.listLoadingsub = true;
          backstage.DelActChannelCfg(this, params);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
          this.listLoadingsub = false;
          this.listLoading = false;
        });
    },
    // 终止活动
    NotEnableActChannelCfg(row) {
      var multis = [];
      var params = new URLSearchParams();
      if (row == undefined || row == "") {
        var arr = this.multipleSelection;
        if (arr == undefined || arr.length <= 0) {
          this.$message({
            showClose: true,
            message: "请至少选中一行",
            type: "error",
          });
          this.listLoading = false;
          return;
        } else {
          for (var i = 0; i < arr.length; i++) {
            multis.push(arr[i].id);
          }
          params.append("delds", JSON.stringify(multis));
        }
      } else {
        multis.push(row.id);
        params.append("delds", JSON.stringify(multis));
      }
      this.$confirm("确认终止吗？终止后,线下支付将无法进行单品优化", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "error",
      })
        .then((a) => {
          this.listLoading = true;
          backstage.NotEnableActChannelCfg(this, params);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
          this.listLoading = false;
        });
    },
    // 查询
    fetchData() {
      this.listLoading = true;
      var params = new URLSearchParams();
      params.append(
        "Parms",
        '{"page":' +
          this.listQuery.page +
          ',"rows":' +
          this.listQuery.limit +
          "}"
      );
      var user = JSON.parse(sessionStorage.getItem("userinfo"));
      params.append(
        "CpnID",
        this.form.cpnID == "" ? user.cpnId : this.form.cpnID
      );
      params.append("ActName", this.listQuery.title);
      params.append("ActTyp", 0);
      // params.append("TrialStt", this.listQuery.trialStt);

      // params.append("CpnID", this.logincpnid);
      backstage.GetActChannelCfgLst(this, params);
    },
  },
};
// 后台事件
var backstage = {
  UpFile: function (thisobj, params) {
    AjaxUpload(
      this,
      "UploadFile",
      params,
      "post",
      function (res) {
        var body = res.data;
        if (body.success) {
          thisobj.filedata.push(body.data);
          thisobj.$message({
            showClose: true,
            message: "上传成功",
            type: "success",
            duration: 3000,
          });
        } else {
          l;
          thisobj.$message({
            showClose: true,
            message: body.message,
            type: "error",
          });
        }
      },
      function (error) {
        thisobj.$message({
          type: "error",
          showClose: true,
          duration: 60000,
          message: "请求失败! error:" + error,
        });
      }
    );
  },
  GetPayTypeList: function (thisobj) {
    SelectAjax(
      "GetPayTypeList?val=&pychanelid=" + thisobj.form.payChannel,
      function (response) {
        var body = response.data;
        thisobj.paytypeoptions = [];
        body.data.forEach((element) => {
          thisobj.paytypeoptions.push({
            value: element.value,
            label: element.text,
          });
        });
      },
      function (error) {}
    );
  },
  GetEnum_TrialStt: function (thisobj, isEmpty) {
    SelectAjax(
      "GetEnum_TrialStt?isEmpty=" + isEmpty + "+&code=0",
      function (response) {
        var body = response.data;

        thisobj.trialSttoptions = [];
        body.data.forEach((element) => {
          thisobj.trialSttoptions.push({
            value: element.value,
            label: element.text,
          });
        });
      },
      function (error) {}
    );
  },
  GetPyChannelSelectListItems: function (thisobj) {
    SelectAjax(
      "GetPyChannelSelectListItems?val=",
      function (response) {
        var body = response.data;
        thisobj.paytychanneloptions = [];
        body.data.forEach((element) => {
          thisobj.paytychanneloptions.push({
            value: element.value,
            label: element.text,
          });
        });
      },
      function (error) {}
    );
  },
  // 获取ActChannelCfg集合
  GetActChannelCfgLst: function (thisobj, params) {
    AjaxToken(
      thisobj,
      "GetActChannelCfgLstProrate",
      params,
      "post",
      function (res) {
        thisobj.listLoading = false;
        var body = res.data.data;
        thisobj.ActChannelCfgData = [];
        thisobj.ActChannelCfgData = body.rows;
        thisobj.listQuery.page = body.page;
        thisobj.listQuery.total = body.records;
      },
      function (err) {
        thisobj.listLoading = false;
      }
    );
  },
  // 获取ActChannelCfg集合(子事件)
  GetActChannelCfgLstSub: function (thisobj, params) {
    AjaxToken(
      thisobj,
      "GetActChannelCfgLstProrate",
      params,
      "post",
      function (res) {
        thisobj.listLoading = false;
        thisobj.listLoadingsub = false;
        var body = res.data.data;
        thisobj.ActChannelCfgDataSub = [];
        thisobj.ActChannelCfgDataSub = body.rows;
      },
      function (err) {
        thisobj.listLoading = false;
      }
    );
  },
  // 获取ActChannelCfg集合
  GetCpnActCfgInfoAct: function (thisobj, params) {
    AjaxTokenNotasync(
      thisobj,
      "GetCpnActCfgInfoAct",
      params,
      "post",
      function (res) {
        thisobj.listLoading = false;
        thisobj.cpnorgLoading = false;
        var body = res.data.data;
        thisobj.CpnActCfgInfos = body.rows;

        thisobj.listQueryAct.page = body.page;
        thisobj.listQueryAct.total = body.records;
        var isselect = false;
        var newobt = thisobj.SecmultipleSelectionAct;
        setTimeout(function () {
          thisobj.CpnActCfgInfos.forEach((element) => {
            element.isRead = false;

            newobt.forEach((b) => {
              if (element.id == b.id) {
                isselect = true;
                try {
                  thisobj.$refs.multipleTable2.toggleRowSelection(element);
                } catch (error) {}
              }
            });
          });
          if (!isselect) {
            thisobj.$refs.multipleTable2.clearSelection();
          }
        }, 500);
      },
      function (err) {
        thisobj.listLoading = false;
        thisobj.cpnorgLoading = false;
      }
    );
  },
  // 获取已选账户集合
  GetCpnActCfgInfoAct2: function (thisobj, params) {
    AjaxTokenNotasync(
      thisobj,
      "GetCpnActCfgInfoAct",
      params,
      "post",
      function (res) {
        var body = res.data.data;
        if (res.data.data != null) {
          var isselect = false;
          body.rows.forEach((element) => {
            if (element.isEnable) {
              isselect = true;
              thisobj.SecmultipleSelectionAct.push(element);
            }
          });
        } else {
          thisobj.$refs.multipleTable2.clearSelection();
        }
      },
      function (err) {
        thisobj.listLoading = false;
        thisobj.cpnorgLoading = false;
      }
    );
  },
  CpnActCfgInfoActRlue: function (thisobj, params) {
    AjaxTokenNotasync(
      thisobj,
      "CpnActCfgInfoActRlue",
      params,
      "post",
      function (res) {
        thisobj.cpnActCfgInfoActRlue = [];
        thisobj.allmony = 0;
        if (!res.data.success) {
          thisobj.isnext = false;
          thisobj.$message({
            showClose: true,
            message: res.data.message,
            type: "error",
          });
        } else {
          thisobj.isnext = true;
          var body = res.data.data;
          thisobj.cpnActCfgInfoActRlue = body;
          thisobj.allmony = 0;
          thisobj.cpnActCfgInfoActRlue.forEach((a) => {
            thisobj.allmony += parseInt(a.limitMny);
            thisobj.rules_form.LimitCyl = a.limitCyl;
          });
        }
      },
      function (err) {
        thisobj.listLoading = false;
        thisobj.cpnorgLoading = false;
      }
    );
  },
  SaveActChannelCfg: function (thisobj, params, loading) {
    AjaxToken(
      thisobj,
      "SaveActChannelCfgGoods",
      params,
      "post",
      function (res) {
        loading.close();
        var body = res.data;
        if (body.success) {
          thisobj.$message({
            showClose: true,
            message: "操作成功,请等待审核结果",
            type: "success",
            duration: 3000,
          });
          thisobj.dialogFormVisible = false;
          thisobj.form.rules_formdata = [];
          thisobj.listQuery.page = 1;
          thisobj.fetchData();
          thisobj.feachDataActChannelCfgLstSub();
        } else {
          thisobj.listLoading = false;
          thisobj.listLoadingsub = false;
          thisobj.$message({
            showClose: true,
            message: body.message,
            type: "error",
            duration: 5000,
          });
          thisobj.form.rules_formdata = [];
        }
      },
      function (err) {
        loading.close();
        thisobj.listLoadingsub = false;
      }
    );
  },
  DelActChannelCfg: function (thisobj, params) {
    AjaxToken(
      thisobj,
      "DelActChannelCfg",
      params,
      "post",
      function (res) {
        thisobj.listLoading = false;
        thisobj.listLoadingsub = false;
        var body = res.data;
        if (body.success) {
          thisobj.$message({
            showClose: true,
            message: body.message,
            type: "success",
            duration: 3000,
          });
          thisobj.fetchData();
          thisobj.feachDataActChannelCfgLstSub();
          thisobj.dialogFormVisible = false;
        } else {
          thisobj.$message({
            showClose: true,
            message: body.message,
            type: "error",
            duration: 5000,
          });
        }
      },
      function (err) {
        thisobj.listLoading = false;
        thisobj.listLoadingsub = false;
      }
    );
  },
  NotEnableActChannelCfg: function (thisobj, params) {
    AjaxToken(
      thisobj,
      "NotEnableActChannelCfg",
      params,
      "post",
      function (res) {
        thisobj.listLoading = false;
        var body = res.data;
        if (body.success) {
          thisobj.$message({
            showClose: true,
            message: body.message,
            type: "success",
            duration: 3000,
          });
          thisobj.fetchData();
          thisobj.feachDataActChannelCfgLstSub();
          thisobj.dialogFormVisible = false;
        } else {
          thisobj.$message({
            showClose: true,
            message: body.message,
            type: "error",
          });
        }
      },
      function (err) {}
    );
  },
  GeCpntListItems: function (thisobj) {
    SelectAjax(
      "GeCpntListItems?val=" + thisobj.form.cpnID + "",
      function (response) {
        var body = response.data;
        thisobj.cpnoptions = [];
        body.data.forEach((element) => {
          thisobj.cpnoptions.push({
            value: element.value,
            label: element.text,
          });
        });
      },
      function (error) {}
    );
  },
  GeCpnPyMchinRctOrgs: function (thisobj) {
    SelectAjax(
      "GeCpnPyMchinRctOrgs?val=" + thisobj.form.pyMchinID + "",
      function (response) {
        var body = response.data;
        thisobj.selectOrgs = body.data.checkOrg;
        thisobj.form.orgID = thisobj.selectOrgs[0];
      },
      function (error) {}
    );
  },
  GeCpnPyMchinRctListItems: function (thisobj) {
    SelectAjax(
      "GeCpnPyMchinRctListItems?CpnID=" +
        thisobj.form.cpnID +
        "&PyMchinId=" +
        thisobj.form.pyMchinID +
        "&OrgID=" +
        thisobj.form.orgID +
        "",
      function (response) {
        var body = response.data;
        thisobj.cpnPyMchinRctListoptions = [];
        body.data.forEach((element) => {
          thisobj.cpnPyMchinRctListoptions.push({
            value: element.value,
            label: element.text,
          });
        });
      },
      function (error) {}
    );
  },
  GetCpnOrgList: function (thisobj, cpnid) {
    SelectAjax(
      "GetCpnOrgList?cpnid=" +
        cpnid +
        "&orgid=" +
        thisobj.form.orgID +
        "&isempty=true",
      function (response) {
        var body = response.data;
        thisobj.orgoptions = [];
        body.data.forEach((element) => {
          thisobj.orgoptions.push({
            value: element.value,
            label: element.text,
          });
        });
      },
      function (error) {}
    );
  },
  compareTime: function (startDate, endDate) {
    if (
      startDate.length > 0 &&
      endDate.length > 0 &&
      startDate != "1970/1/1" &&
      endDate != "1970/1/1"
    ) {
      var allStartDate = new Date(startDate);
      var allEndDate = new Date(endDate);
      if (allStartDate.getTime() >= allEndDate.getTime()) {
        return false;
      } else {
        return true;
      }
    } else {
      return true;
    }
  },
  // 获取活动详情
  GetActChannelCfgBllLstByActId: function (thisobj, params) {
    AjaxToken(
      thisobj,
      "GetActChannelCfgBllLstByActId",
      params,
      "post",
      function (res) {
        thisobj.ActDeialFormLoading = false;
        var body = res.data.data;
        if (body.rows.length > 0) {
          // 加载右边信息
          thisobj.ActDeialForm = body.rows[0];
        }
      },
      function (err) {
        thisobj.ActDeialFormLoading = false;
      }
    );
  },
};
</script>
<style scoped>
.red {
  color: red;
}

.green {
  color: #309a3a;
}

.orgaine {
  color: #ff9a22;
}

.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}

.clearfix:after {
  clear: both;
}

.box-card {
  margin-bottom: 10px;
}

.Rule span {
  color: red;
  position: relative;
  top: -37px;
  left: 63px;
}

.el-textarea__inner1 {
  height: 200px !important;
  margin-left: 68px;
  position: relative;
  top: -30px;
}

.prorate_info_orgs {
  width: 100%;
  height: 94px;
  border: 1px solid #c3cad2;
  opacity: 1;
  border-radius: 4px;
  margin-top: 10px;
  padding: 10px;
}

.seach_org_left {
  float: left;
  width: 70%;
}

.seach_org {
  clear: both;
  overflow: hidden;
  width: 100%;
}

.seach_org_left_second {
  height: 300px;
  background: #ffffff;
  border: 1px solid #c3cad2;
  opacity: 1;
  border-radius: 4px;
  padding: 10px;
  margin-top: 10px;
  overflow: auto;
}

.seach_org_left_second2 {
  height: 300px;
  background: #ffffff;
  border: 1px solid #c3cad2;
  opacity: 1;
  border-radius: 4px;
  padding: 10px;
  margin-top: 10px;
  overflow: auto;
}

.seach_org_right {
  float: left;
  width: 30%;
  overflow: auto;
}

.seach_org_right_second {
  height: 300px;
  background: #ffffff;
  opacity: 1;
  border-radius: 4px;
  margin-top: 10px;
  margin-bottom: 10px;
}

.seach_org_right_second2 {
  height: 350px;
  background: #ffffff;
  opacity: 1;
  border-radius: 4px;
  margin-top: 10px;
  margin-bottom: 10px;
}

.select_org {
  background: #409eff;
  border: 1px solid #409eff;
  opacity: 1;
  border-radius: 18px;
  line-height: 18px;
  text-align: center;
  color: white;
  font-size: 14px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  display: inline-block;
  padding: 5px 10px 5px 10px;
  margin: 10px 5px 0px 10px;
  position: relative;
}

.orgclose {
  position: absolute;
  top: -9px;
  right: -5px;
  cursor: pointer;
}

.clear_all {
  float: right;
  width: 28px;
  height: 14px;
  font-size: 14px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  /* line-height: 24px; */
  color: #409eff;
  opacity: 1;
  cursor: pointer;
}

.cpnorgdata_div {
  width: 100%;
  height: 80%;
}

.cpnActCfgInfoActRlue {
  border-radius: 8px;
  border: 1px solid #c3cad2;
  opacity: 1;
  overflow: hidden;
}

.sumlimitMny {
  height: 30px;
  font-size: 14px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  line-height: 28px;
  color: #959ea8;
  opacity: 1;
  float: right;
  margin-right: 10px;
}

.sumlimitMny span {
  color: #304156;
  opacity: 1;
}

.rules_Cfg {
  margin-bottom: 10px;
}

.rules_Cfg span {
  margin-right: 10px;
}

.infocontent_line {
  margin-top: 20px;
  display: flex;
  justify-content: flex-start;
  text-align: left;
}

.infocontent_item_1 {
  font-size: 14px;
  width: 100%;
}

.first_Subtitle {
  height: 20px;
  font-size: 20px;
  font-family: Source Han Sans CN;
  font-weight: 600;
  line-height: 34px;
  color: #304156;
  opacity: 1;
}

.sub_titie_info {
  margin-left: 20px;
}

.sub_table_info {
  margin-top: 20px;
}

.sub_btton {
  margin: 19px 0px 10px -1px;
}

.sub_btton button {
  border: 1px dashed #409eff;
  opacity: 1;
  background: transparent;
  color: #409eff;
}

.linediv {
  width: 100%;
  height: 0;
  border-bottom: 1px dashed #e6e6e6;
  margin-top: 20px;
}

.infocontent_line {
  margin-top: 20px;
  display: flex;
  justify-content: flex-start;
  text-align: left;
}

.infocontent_item_2 {
  font-size: 14px;
  width: 40%;
}

.infocontent_item_3 {
  font-size: 14px;
  width: 30%;
}

.infocontent_item_auto {
  font-size: 14px;
}

.infocontent_item_name {
  color: #959ea8;
}

.infocontent_item_content {
  color: #304156;
}

.macinact {
  width: 18px;
  height: 18px;
  display: inline-block;
  background: #1ab448;
  border-radius: 50%;
  line-height: 16px;
  opacity: 1;
  font-size: 12px;
  color: white;
  text-align: center;
  margin-right: 5px;
  /* padding-left: 3px;
  position: absolute;
  left: -10px;
  top: 13px; */
}

/*设置列表transition-group的name为list的入场以及离场动画效果*/

/* 淡入淡出动画 */
/* .list-enter,
  .list-leave-to {
    opacity: 0;
  }

  .list-enter-to,
  .list-leave {
    opacity: 1;
  }
  .list-enter-active,
  .list-leave-active {
    transition: all 3s;
  } */

.list-enter {
  opacity: 0;
  transform: translateY(80px);
}

.list-leave-to {
  opacity: 0;
  transform: translateY(80px);
}

.list-enter-to,
.list-leave {
  opacity: 1;
}

.list-enter-active,
.list-leave-active {
  transition: all 1s;
}
.el-icon-info {
  margin-left: 10px !important;
  font-size: 18px !important;
  vertical-align: middle !important;
}

.list-enter-active,
.list-leave-active {
  transition: all 1s;
}
</style>
<style>
.prorate_info .el-form-item--medium .el-form-item__label {
  width: 100px;
}

.prorate_info .el-form-item--medium .el-form-item__content {
  width: 270px;
}

.seach_org_left .pagination-container {
  text-align: center;
  float: none;
  margin-top: 10px;
}

.cpnActCfgInfoActRlue .el-table td {
  border-bottom: none;
}

.ActChannelCfgInfo .el-dialog__header {
  padding: 0px;
  padding-bottom: 0px;
}

.ActChannelCfgActDeial .el-dialog__body {
  padding-top: 0px;
}

.goodsdialg .el-textarea__inner {
  height: 100px;
}

.goodsdialg .el-dialog__body {
  overflow: hidden;
}

.goodsdialg .el-dialog__header {
  padding: 0px;
  padding-bottom: 0px;
}
</style>
